package com.xbongbong.pro.enums.businessrule.enums;

import com.xbongbong.saas.enums.OperateModuleTypeEnum;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import lombok.Getter;

import java.util.Objects;

/**
 * 业务数据中的日志
 * @author 吴峰
 * @version v1.0
 * @date 2019/11/12 10:45
 * @since v1.0
 */
@Getter
public enum BusinessLoggerEnum {

    /**
     * crm 模块
     */
    CUSTOMER(XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode(), OperateModuleTypeEnum.CUSTOMER),
    OPPORTUNITY(XbbRefTypeEnum.SALES_OPPORTUNITY.getCode(), OperateModuleTypeEnum.OPPORTUNITY),
    CONTRACT(XbbRefTypeEnum.CONTRACT.getCode(), OperateModuleTypeEnum.CONTRACT),
    CONTACT(XbbRefTypeEnum.CONTACT.getCode(), OperateModuleTypeEnum.CONTACT),
    CUSTOMER_COMMUNICATE(XbbRefTypeEnum.CUSTOMER_COMMUNICATE.getCode(), OperateModuleTypeEnum.CustomerCommunicate),
    COMMUNICATE_PLAN(XbbRefTypeEnum.COMMUNICATE_PLAN.getCode(), OperateModuleTypeEnum.CommunicatePlan),
    QUOTATION(XbbRefTypeEnum.QUOTATION.getCode(), OperateModuleTypeEnum.QUOTATION),
    REFUND(XbbRefTypeEnum.REFUND.getCode(), OperateModuleTypeEnum.REFUND),
    WORK_REPORT(XbbRefTypeEnum.WORK_REPORT.getCode(), OperateModuleTypeEnum.WORKREPORT),
    /**
     * 产品
     */
    PRODUCT(XbbRefTypeEnum.PRODUCT.getCode(), OperateModuleTypeEnum.PRODUCT),

    /**
     * 资金管理
     */
    PAYMENT(XbbRefTypeEnum.PAYMENT.getCode(), OperateModuleTypeEnum.PaymentManage),
    PAY_PLAN(XbbRefTypeEnum.PAY_PLAN.getCode(), OperateModuleTypeEnum.PayManage),
    PAY_SHEET(XbbRefTypeEnum.PAY_SHEET.getCode(), OperateModuleTypeEnum.PAY_SHEET),
    PAYMENT_SHEET(XbbRefTypeEnum.PAYMENT_SHEET.getCode(), OperateModuleTypeEnum.PAYMENT_SHEET),
    INVOICE(XbbRefTypeEnum.INVOICE.getCode(), OperateModuleTypeEnum.INVOICE),
    CUSTOMER_STATEMENT(XbbRefTypeEnum.CUSTOMER_STATEMENT.getCode(), OperateModuleTypeEnum.CUSTOMER_STATEMENT),
    OTHER_INCOME(XbbRefTypeEnum.OTHER_INCOME.getCode(), OperateModuleTypeEnum.OTHER_FUND_MANAGEMENT),
    OTHER_EXPENSE(XbbRefTypeEnum.OTHER_EXPENSE.getCode(), OperateModuleTypeEnum.OTHER_FUND_MANAGEMENT),
    FUND_TRANSFER(XbbRefTypeEnum.FUND_TRANSFER.getCode(), OperateModuleTypeEnum.FUND_TRANSFER),


    /**
     * 进销存
     */
    SUPPLIER(XbbRefTypeEnum.SUPPLIER.getCode(), OperateModuleTypeEnum.SUPPLIER),
    SUPPLIER_CONTACT(XbbRefTypeEnum.SUPPLIER_CONTACT.getCode(), OperateModuleTypeEnum.SUPPLIER_CONTACT),
    SUPPLIER_COMMUNICATE(XbbRefTypeEnum.SUPPLIER_COMMUNICATE.getCode(), OperateModuleTypeEnum.SUPPLIER_COMMUNICATE),
    PURCHASE(XbbRefTypeEnum.PURCHASE.getCode(), OperateModuleTypeEnum.PURCHASE),
    RETURNED_PURCHASE(XbbRefTypeEnum.RETURNED_PURCHASE.getCode(), OperateModuleTypeEnum.RETURN_PURCHASE),
    BOM_BILL(XbbRefTypeEnum.BOM_BILL.getCode(), OperateModuleTypeEnum.BOMBILL),
    PRODUCTION_ORDER(XbbRefTypeEnum.PRODUCTION_ORDER.getCode(), OperateModuleTypeEnum.PRODUCTION_ORDER),
    ASSEMBLE(XbbRefTypeEnum.ASSEMBLE.getCode(), OperateModuleTypeEnum.ASSEMBLE),
    INSTOCK(XbbRefTypeEnum.INSTOCK.getCode(), OperateModuleTypeEnum.INSTOCK),
    PURCHASE_INSTOCK(XbbRefTypeEnum.PURCHASE_INSTOCK.getCode(), OperateModuleTypeEnum.PURCHASE_INSTOCK),
    REFUND_INSTOCK(XbbRefTypeEnum.REFUND_INSTOCK.getCode(), OperateModuleTypeEnum.PURCHASE_INSTOCK),
    OTHER_INSTOCK(XbbRefTypeEnum.OTHER_INSTOCK.getCode(), OperateModuleTypeEnum.INSTOCK),
    PRODUCTION_INSTOCK(XbbRefTypeEnum.PRODUCTION_INSTOCK.getCode(), OperateModuleTypeEnum.PRODUCTION_INSTOCK),
    RETURNED_MATERIEL_INSTOCK(XbbRefTypeEnum.RETURNED_MATERIEL_INSTOCK.getCode(), OperateModuleTypeEnum.RETURNED_MATERIEL_INSTOCK),

    OUTSTOCK(XbbRefTypeEnum.OUTSTOCK.getCode(), OperateModuleTypeEnum.OUTSTOCK),
    CONTRACT_OUTSTOCK(XbbRefTypeEnum.CONTRACT_OUTSTOCK.getCode(), OperateModuleTypeEnum.CONTRACT_OUTSTOCK),
    RETURNED_PURCHASE_OUTSTOCK(XbbRefTypeEnum.RETURNED_PURCHASE_OUTSTOCK.getCode(), OperateModuleTypeEnum.RETURNED_PURCHASE_OUTSTOCK),
    PRODUCTION_MATERIEL_OUTSTOCK(XbbRefTypeEnum.PRODUCTION_MATERIEL_OUTSTOCK.getCode(), OperateModuleTypeEnum.PRODUCTION_MATERIEL_OUTSTOCK),
    OTHER_OUTSTOCK(XbbRefTypeEnum.OTHER_OUTSTOCK.getCode(), OperateModuleTypeEnum.OUTSTOCK),
    WORK_ORDER_OUTSTOCK(XbbRefTypeEnum.WORK_ORDER_OUTSTOCK.getCode(), OperateModuleTypeEnum.WORK_ORDER_OUTSTOCK),

    INVENTORY(XbbRefTypeEnum.INVENTORY.getCode(), OperateModuleTypeEnum.INVENTORY),
    TRANSFER(XbbRefTypeEnum.TRANSFER.getCode(), OperateModuleTypeEnum.TRANSFER),
    WAREHOUSE(XbbRefTypeEnum.WAREHOUSE.getCode(), OperateModuleTypeEnum.WAREHOUSE),
    /**
     * 工单
     */
    WORK_ORDER(XbbRefTypeEnum.WORK_ORDER.getCode(), OperateModuleTypeEnum.WORK),

    /**
     * 市场管理
     */
    CLUE(XbbRefTypeEnum.CLUE.getCode(), OperateModuleTypeEnum.CLUE),
    MARKET_ACTIVITY(XbbRefTypeEnum.MARKET_ACTIVITY.getCode(), OperateModuleTypeEnum.MARKET_ACTIVITY),

    /**
     * 竞争对手
     */
    competitor(XbbRefTypeEnum.COMPETITOR.getCode(),OperateModuleTypeEnum.COMPETITOR),
    /**
     * 服务项目
     */
    SERVICE_PROJECT(XbbRefTypeEnum.SERVICE_PROJECT.getCode(), OperateModuleTypeEnum.SERVICE_PROJECT),
    /**
     * 工单v2
     */
    WORK_ORDER_V2(XbbRefTypeEnum.WORK_ORDER_V2.getCode(), OperateModuleTypeEnum.WORK_ORDER_V2),
    /**
     * 回执单
     */
    RECEIPT_ORDER(XbbRefTypeEnum.RECEIPT_ORDER.getCode(), OperateModuleTypeEnum.RECEIPT_ORDER),

    UNKNOWN(404, OperateModuleTypeEnum.UNKNOWN),
    ;

    private Integer code;

    private OperateModuleTypeEnum operateModuleTypeEnum;

    BusinessLoggerEnum(Integer code, OperateModuleTypeEnum operateModuleTypeEnum) {
        this.code = code;
        this.operateModuleTypeEnum = operateModuleTypeEnum;
    }

    public static BusinessLoggerEnum getByCode(Integer code) {
        for (BusinessLoggerEnum businessLoggerEnum: values()) {
            if (Objects.equals(businessLoggerEnum.getCode(), code)) {
                return businessLoggerEnum;
            }
        }
        return UNKNOWN;
    }
}
